#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:
    bool isAnagram(string s, string t) {
        vector<int> alpha(26, 0);

        for (char i : s) {
            ++alpha[i - 'a'];
        }

        for (char i : t) {
            --alpha[i - 'a'];
        }

        for (int i : alpha) {
            if (i != 0) {
                return false;
            }
        }

        return true;
    }
};

int main() {
    Solution s;

    string s1{"anagram"}, t1{"nagaram"};
    string s2{"rat"}, t2{"car"};

    s.isAnagram(s1, t1);
    assert(s.isAnagram(s1, t1) == true);
    assert(s.isAnagram(s2, t2) == false);

    return 0;
}